//
//  PickDateView.m
//  Yihubang
//
//  Created by hyu on 2016/12/5.
//  Copyright © 2016年 xmy. All rights reserved.
//

#import "PickDateView.h"

@implementation PickDateView

-(void)awakeFromNib{
    [super awakeFromNib];
    [self.pickDateView setValue:[UIColor colorWithHex:0x525252] forKey:@"textColor"];
    self.pickDateView.maximumDate = [NSDate date];
    [self.cancelBtn addTarget:self action:@selector(removeFromview:) forControlEvents:UIControlEventTouchUpInside];
    [self.accomplishBtn addTarget:self action:@selector(accomplishPickDate) forControlEvents:UIControlEventTouchUpInside];
}


-(void)accomplishPickDate{
    NSDate *pickerDate = self.pickDateView.date;
    NSDateFormatter *pickerFormatter = [[NSDateFormatter alloc] init];
    [pickerFormatter setDateFormat:@"yyyy-MM-dd"];
    NSString *dateString = [pickerFormatter stringFromDate:pickerDate];
//    [self.delegate ChangeDate:dateString];
    [self removeFromview:dateString];
}
-(void)removeFromview:(id)dateString{
    [UIView animateWithDuration:0.4 animations:^{
        self.frame = CGRectMake(0, ScreenHeight, ScreenWidth, 223);
    } completion:^(BOOL finish){
        [self removeFromSuperview];
        [self.delegate ChangeDate:[dateString isKindOfClass:[NSString class]] ? dateString : nil];
    }];
}
@end
